package io.aircraft.modules.wms.service.impl;

import io.aircraft.common.service.impl.BaseServiceImpl;
import io.aircraft.modules.wms.dao.AllotQueueDao;
import io.aircraft.modules.wms.entity.AllotQueueEntity;
import io.aircraft.modules.wms.service.AllotQueueService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class AllotQueueServiceImpl extends BaseServiceImpl<AllotQueueDao, AllotQueueEntity> implements AllotQueueService {
    /**
     * 自动配货逻辑
     * @param waveNo 波次编号
     * @param ids   orderId数组
     * @return
     */
    @Override
    public int batchInsertAllotQueueById(String waveNo, Long[] ids) {
        List<Long> idList = Arrays.asList(ids);
        List<AllotQueueEntity> queueList = idList.stream().map(id -> {
            AllotQueueEntity entity = new AllotQueueEntity();
            entity.setOrderId(id);
            entity.setWaveNo(waveNo);
            return entity;
        }).collect(Collectors.toList());
        return baseDao.batchInsertAllotQueue(queueList);
    }
}
